/* $RCSFile: ShortcutAll.ascx.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/AddonNice/PageModules/Shortcut/ShortcutAll.ascx.cs $
 * $log$
 * Revision 20 2010/08/09 10:51:22  christian.surieux
 *   Added Log comment to all .aspx .ascx .master files
 * Revision 19 2010/08/09 09:43:59  christian.surieux
 *   Added Log to cs sources files
 * Revision 6 2010/08/06 19:56:26  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using AddonNice.Core;
using AddonNice.Diagnostics;
using AddonNice.UI;
using AddonNice.UI.WebControls;
using AddonNice.UI.DataTypes;
using AddonNice.Configuration;
using AddonNice.Configuration.Settings;
using AddonNice.Settings;

using Trace2    =   System.Diagnostics.Trace;

namespace AddonNice.PageModules.Shortcut
{
    public class AAStr
    {
        public const string AllLinkedModule   =   "SHORTCUTALL_LINKEDMODULE";
    }
    /// <summary>
    /// Initializer class for ShortcutAll 
    /// </summary>
    public class ShortcutAllSI : PortalModuleControlSI
    {
        public ShortcutAllSI(ModuleSettingsDictionary bSettings,ISettingsOwner pm) : base()
        {
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]ShortcutAllSI Ctor BEG.",ModuleTraceSwitch.Sw.Info);
            InitSettings(bSettings,pm);
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]ShortcutAllSI Ctor END.",ModuleTraceSwitch.Sw.Info);
        }
 
        public override void InitSettings(ModuleSettingsDictionary bSettings,ISettingsOwner pm)
        {             
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]ShortcutAllSI InitSettings BEG.",ModuleTraceSwitch.Sw.Info);
            
            base.InitSettings(bSettings,pm);

            string extgrp                   =   pm.ExtendedResourcesGroup;
            
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
			    Trace2.WriteLine("[C]ShortCutAll Ctor BEG.",ModuleTraceSwitch.Sw.Info);
            
            // Remove shortcut, set setcutAll
            //No more needed now that initializer is separated from Ctor bSettings.Remove(AStr.LinkedModule);

			//Overrides the base setting
            DataTable tbMod                 =   new ModulesDB().GetModulesAllPortals();
            CustomListDataType ModList      =   new CustomListDataType(tbMod, "ModuleTitle", "ModuleID");
			SettingItemSpecial LinkedModule =   new SettingItemSpecial(AAStr.AllLinkedModule,ModList);
			LinkedModule.Required           =   true;
			LinkedModule.Order              =   1;
			LinkedModule.Value              =   "0";
			LinkedModule.ExtendedGroupName  =    extgrp;
            LinkedModule.EnglishName        =   "Shortcut All module";
            LinkedModule.Description        =   "Enter the module linked to this module";
			bSettings.AddSetting(LinkedModule); 

            if ( ModuleTraceSwitch.Sw.TraceVerbose )
                Trace2.WriteLine( "[V]ShortcutAllSI InitSettings END.",ModuleTraceSwitch.Sw.Info);
        }
    }

	/// <summary>
	/// ShortcutAll module provide a quick way to duplicate
	/// a module content in different page from different portals 
    /// Only difference with Shortcut is that modules come from any portal managed by AddonNice
 	/// </summary>
	public partial class ShortcutAll : Shortcut 
	{
		#region General Implementation
		public override Guid GuidID 
		{
			get
			{
				return new Guid("{B47BC165-91A2-4970-ADC5-5A3B727469E3}");
			}
		}
		#endregion

        /// <summary>
        /// CTor
        /// </summary>
        public ShortcutAll()
		{
            if ( ModuleTraceSwitch.Sw.TraceVerbose )
			    Trace2.WriteLine("[C]ShortCutAll Ctor Called.",ModuleTraceSwitch.Sw.Info);
		}

        public override string ExtendedResourcesGroup 
		{
            get
            {
       			const string extgrp             =   "SHORTCUTALL";
                return extgrp;
            }
		}

        public override void InitPortalModuleControl(ModuleSettingsDictionary bSettings)
        {
            PortalModuleInitializer =   new ShortcutAllSI(bSettings,this);
        }

        protected override string ModuleKey
        {
            get
            {
                return AAStr.AllLinkedModule;
            }
        }
	}
}
